﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Description résumée de ZoneService
/// </summary>
/// 
namespace BLL
{
    public class ZoneService
    {
        private IZoneManager zoneManager;

        public ZoneService(IZoneManager zoneManager)
        {
            this.zoneManager = zoneManager;
        }

        public ZONE createZone(string nom)
        {
            ZONE zone = new ZONE();
            zone.NOM = nom;

            try
            {
                this.zoneManager.addZone(zone);
                return zone;
            }

            catch (Exception ex)
            {
                return null;
            }

        }

        public bool deleteZone(int zoneId)
        {
            return zoneManager.deleteZone(zoneId);
        }


        public bool updateZone(int id, string nom)
        {
            try
            {
                ZONE zone = zoneManager.getZoneById(id);
                zone.NOM = nom;

                zoneManager.updateZone();

                return true;
            }

            catch (Exception ex)
            {
                return false;
            }
        }

        public ZONE getZoneById(int id)
        {
            return zoneManager.getZoneById(id);
        }

        public List<ZONE> getAllZones()
        {
            return this.zoneManager.getAllZones();
        }

        public string getNom(int id)
        {
            return this.zoneManager.getNom(id);
        }

        public ZONE getZoneByNom(string nom)
        {
            return zoneManager.getZoneByNom(nom);
        }

    }
}